#Custom Calendar in android studio kotlin
Explore tagged Tumblr posts
Text
Android App Development | Android App Development Company | Android App Development Company in USA

Android app development is indeed a critical process for creating mobile applications that run on the Android operating system. This process involves a series of steps, tools, techniques, and frameworks to bring innovative and user-friendly applications to the vast Android user base. In this article, we will delve deeper into the various aspects of Android app development.
The Android App Development Process Android app development is a comprehensive process that typically involves the following stages:
Ideation and Planning: This is the initial phase where you define the concept of your app, identify your target audience, and outline its key features and functionalities. You also plan the user interface and user experience (UI/UX) design.
Design: In this phase, app designers create wireframes and prototypes to visualize the app's layout and user interactions. The design should be visually appealing, intuitive, and aligned with your brand.
Development: Developers write the actual code for the Android app using programming languages like Java or Kotlin. They use integrated development environments (IDEs) like Android Studio to build and debug the app.
Testing: Quality assurance is crucial to ensure that the app functions correctly and is free of bugs. Testing involves various methodologies, including manual testing, automated testing, and user testing.
Deployment: Once the app is thoroughly tested, it is ready for deployment to the Google Play Store, the official Android app marketplace. Developers need to follow specific guidelines and requirements to publish the app.
Maintenance and Updates: After the app is live, it requires ongoing maintenance to address issues, provide updates, and add new features. User feedback is valuable for improving the app over time.
Android's Advantages Android app development offers several advantages:
Large User Base: Android has a vast global user base, making it an attractive platform for reaching a broad audience.
Open Source: Android is open-source, allowing developers to access and customize the source code to meet specific requirements.
Customization: Developers can customize the user interface to create unique and visually appealing applications, enhancing user engagement.
Versatility: Android is versatile and supports a wide range of app types, from business and productivity apps to social and gaming apps.
Tools and Techniques in Android App Development Editors and IDEs Android Studio: The official IDE for Android development, equipped with powerful tools and features to streamline the development process. Language Resources Java: A widely used programming language for Android app development. Kotlin: A modern, officially supported language that offers concise syntax and enhanced safety features for Android development. Libraries Android Jetpack: A collection of libraries and tools that simplify various aspects of Android app development, including navigation, UI components, and data handling. Retrofit: A popular library for making network requests and handling API interactions. Glide: A fast and efficient image loading library for displaying images in Android apps. Plugins Firebase: Offers a suite of tools for app development, including authentication, cloud storage, and real-time databases. Crashlytics: A powerful crash reporting tool that helps developers identify and fix issues in their apps. Service Offerings in Android App Development Android App Development for Business Android business apps are designed to enhance enterprise mobility and productivity in corporate settings. They can include features like data management, collaboration tools, and secure access to company resources.
Android App Development for Productivity Productivity apps for Android leverage the platform's versatility to boost user efficiency. These apps can include task management, note-taking, calendar integration, and document editing features.
Android Social App Development Social apps for Android are focused on user engagement and interaction. They facilitate communication, sharing, and social experiences, helping businesses build a strong online presence and connect with their audience.
Frameworks Competency Corona SDK Corona SDK is known for its rapid development capabilities, making it a favorite among game developers. It offers an intuitive API and supports Lua programming for quick and efficient development.
Phonegap Phonegap is suitable for web developers, allowing them to use HTML5, CSS, and JavaScript to create cross-platform apps. It's backed by Adobe and offers support for various platforms, including Windows phones.
Xamarin Xamarin allows developers to write code in C# and deploy it on Android, Windows, and iOS. It also facilitates cloud testing and app monitoring for improved performance.
Sencha Touch 2 Sencha Touch 2 is a JavaScript and HTML5 framework designed for creating secure business applications across multiple devices. It includes an MVC system, numerous built-in components, and supports direct publishing to Google Play.
In conclusion, Android app development is a dynamic and essential process for businesses and developers looking to reach a vast mobile audience. With a robust ecosystem of tools, languages, libraries, and frameworks, Android offers the flexibility and scalability needed to create innovative and user-friendly applications. Whether you're developing business, productivity, or social apps, the Android platform provides a fertile ground for turning your ideas into reality. To succeed in this competitive landscape, partnering with experienced Android app development companies like DCS in the USA can help businesses meet their evolving customer needs and stand out in the market.
0 notes
Link
The custom Calendar in android studio kotlin
_______________________________________________ Xml _______________________________________________ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://ift.tt/nIICcg" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg_bottom_sheet_dialog_fragment" android:orientation="vertical"> <androidx.appcompat.widget.LinearLayoutCompat android:id="@+id/ll_Main" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_24" android:orientation="vertical"> <com.android.showMotionRealtor.feature.dasboard.view.schedule.customcalender.CustomCalendar android:id="@+id/custom_calender" android:layout_width="match_parent" android:layout_height="wrap_content" /> </androidx.appcompat.widget.LinearLayoutCompat> </LinearLayout> _______________________________________________ CustomCalendar.kt _______________________________________________ package com.android.showMotionRealtor.feature.dasboard.view.schedule.customcalender import android.app.Dialog import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import com.android.showMotionRealtor.R import com.android.showMotionRealtor.core.util.MAX_CALENDAR_COLUMN import com.android.showMotionRealtor.core.util.mEventDateFormat import com.android.showMotionRealtor.model.CalendarData import com.android.showMotionRealtor.model.EventMessage import com.zendesk.util.DateUtils import java.text.ParseException import java.text.SimpleDateFormat import java.util.* import kotlin.collections.ArrayList /** * Created by Jeetesh Surana. */ class CustomCalendar : LinearLayout { // private var mUserSelectedDate: Long? = 0L private var mDialog : Dialog? = null private var mUserSelectedDate: Date? = null private var previousButton: ImageView? = null private var nextButton: ImageView? = null private var currentDate: TextView? = null private var rvCalender: RecyclerView? = null private val formatter = SimpleDateFormat("MMMM yyyy", Locale.ENGLISH) private val cal = Calendar.getInstance(Locale.ENGLISH) private val calendarData = ArrayList<CalendarData>() private val events: ArrayList<EventMessage> = ArrayList() private var mDateAdapter: DateAdapter? = null private val mWeekName = ArrayList<String>() var mCustomCalenderListener: CustomCalenderListener? = null constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { setWeekName() initializeUILayout() setRecyclerView() setUpCalenderData() setPreviousButtonClickEvent() setNextButtonClickEvent() } constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) private fun initializeUILayout() { val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater val mView = inflater.inflate(R.layout.calendar_layout, this) previousButton = mView.findViewById(R.id.previous_month) nextButton = mView.findViewById(R.id.next_month) currentDate = mView.findViewById(R.id.display_current_date) rvCalender = mView.findViewById(R.id.rv_CustomCalender) } private fun setPreviousButtonClickEvent() { previousButton!!.setOnClickListener { cal.add(Calendar.MONTH, -1) setUpCalenderData() } } private fun setNextButtonClickEvent() { nextButton!!.setOnClickListener { cal.add(Calendar.MONTH, 1) setUpCalenderData() } } private fun setUpCalenderData() { calendarData.clear() val dayValueInCells = ArrayList<Date>() val mCal = cal.clone() as Calendar // set month in cal mCal.set(Calendar.DAY_OF_MONTH, 1) // get the start date in week val firstDayOfTheMonth = mCal.get(Calendar.DAY_OF_WEEK) - 1 mCal.add(Calendar.DAY_OF_MONTH, -firstDayOfTheMonth) //getting dates while (dayValueInCells.size < MAX_CALENDAR_COLUMN) { dayValueInCells.add(mCal.time) mCal.add(Calendar.DAY_OF_MONTH, 1) } //set the title of month val sDate = formatter.format(cal.time) currentDate!!.text = sDate //set the week name for (i in mWeekName.indices) { calendarData.add(CalendarData(null, mWeekName[i], 0, false)) } //set the Dates for (i in dayValueInCells.indices) { if (mUserSelectedDate != null && DateUtils.isSameDay(dayValueInCells[i], mUserSelectedDate)) { calendarData.add(CalendarData(dayValueInCells[i], null, 1, true)) mDateAdapter!!.currentSelectedDatePosition(position = i) } else { calendarData.add(CalendarData(dayValueInCells[i], null, 1, false)) } } //notify adapter mDateAdapter!!.notifyDataSetChanged() } private fun setWeekName() { mWeekName.clear() mWeekName.add("S") mWeekName.add("M") mWeekName.add("T") mWeekName.add("W") mWeekName.add("T") mWeekName.add("F") mWeekName.add("S") } private fun setRecyclerView() { val dateToday = Date() val reminderDate = convertStringToDate("31-08-2019") val reminderDate2 = convertStringToDate("25-08-2019") if (reminderDate!!.after(dateToday) || reminderDate == dateToday) { events.add(EventMessage(1, "Birthday", reminderDate)) } if (reminderDate2!!.after(dateToday) || reminderDate == dateToday) { events.add(EventMessage(2, "Friendship Day !", reminderDate2)) } val layoutManager = GridLayoutManager(context, 7, RecyclerView.VERTICAL, false) rvCalender!!.layoutManager = layoutManager mDateAdapter = DateAdapter(context, calendarData, cal, events, object : DateAdapter.ItemClickListener { override fun itemClick(position: Int) { if (mDialog != null){ mDialog!!.dismiss() mUserSelectedDate = calendarData[position].monthlyDates!! } } }) rvCalender!!.adapter = mDateAdapter } private fun convertStringToDate(dateInString: String): Date? { val format = SimpleDateFormat(mEventDateFormat, Locale.ENGLISH) var date: Date? = null try { date = format.parse(dateInString) } catch (e: ParseException) { e.printStackTrace() } return date } /*fun setCurrentDate(userSelectedDate: Date) { mUserSelectedDate = userSelectedDate setUpCalenderData() }*/ fun setCalendar(mCal: Calendar) { mUserSelectedDate = mCal.time cal.time = mCal.time setUpCalenderData() } fun getCurrentSelectedDate(): Date { return calendarData[mDateAdapter!!.mLastSelectedDatePosition].monthlyDates!! } fun setCustomCalenderListener(customCalenderListener: CustomCalenderListener) { mCustomCalenderListener = customCalenderListener } fun dismissDialog(dialog: Dialog) { mDialog = dialog } interface CustomCalenderListener { fun currentSelectedDatePosition(position: Int) } } _______________________________________________ DateAdapter.kt _______________________________________________ package com.android.showMotionRealtor.feature.dasboard.view.schedule.customcalender import android.annotation.SuppressLint import android.content.Context import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView import androidx.appcompat.widget.AppCompatImageView import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import com.android.showMotionRealtor.R import com.android.showMotionRealtor.model.CalendarData import com.android.showMotionRealtor.model.EventMessage import java.util.* import kotlin.collections.ArrayList /** * Created by Jeetesh Surana. */ class DateAdapter(var context: Context, var mArrayList: java.util.ArrayList<CalendarData> = ArrayList(), var currentDate: Calendar, val allEvents: ArrayList<EventMessage> = ArrayList(), var mItemClickListener: ItemClickListener) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { var oldPosition: Int = 0 var mLastSelectedDatePosition = -1 private var dateCal = Calendar.getInstance() private var allDate: Int? = null private var displayMonth: Int? = null private var displayYear: Int? = null private var currentMonth: Int? = null private var currentYear: Int? = null override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { var view: View? = null when (viewType) { 0 -> { view = LayoutInflater.from(parent.context).inflate(R.layout.list_days, parent, false) return DaysViewHolder(view!!) } 1 -> { view = LayoutInflater.from(parent.context).inflate(R.layout.list_date, parent, false) return DateViewHolder(view!!) } } return null!! } override fun getItemCount(): Int { return mArrayList.size } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { when (holder.itemViewType) { 0 -> { (holder as DaysViewHolder).bind(mArrayList[position].mDays!!) } 1 -> { dateCal.time = mArrayList[position].monthlyDates!! allDate = dateCal.get(Calendar.DAY_OF_MONTH) displayMonth = dateCal.get(Calendar.MONTH) + 1 displayYear = dateCal.get(Calendar.YEAR) currentMonth = currentDate.get(Calendar.MONTH) + 1 currentYear = currentDate.get(Calendar.YEAR) (holder as DateViewHolder).bind(allDate!!, displayMonth!!, displayYear!!, currentMonth!!, currentYear!!) setSelectionUI((holder).txtDate, position) holder.txtDate.setOnClickListener { mItemClickListener.itemClick(position) if (mLastSelectedDatePosition != -1 && mLastSelectedDatePosition != position) { mArrayList[mLastSelectedDatePosition].isDateSelected = false } mLastSelectedDatePosition = position mArrayList[position].isDateSelected = true notifyDataSetChanged() } val eventCalendar = Calendar.getInstance() for (i in 0 until allEvents.size) { eventCalendar.time = allEvents[i].reminderDate!! if (allDate == eventCalendar.get(Calendar.DAY_OF_MONTH) && displayMonth == eventCalendar.get(Calendar.MONTH) + 1 && displayYear == eventCalendar.get(Calendar.YEAR)) { holder.imgEventIcon.visibility = View.VISIBLE } } } } } //set the selected position private fun setSelectionUI(img: TextView, position: Int) { if (mArrayList[position].isDateSelected) { img.background = context.resources.getDrawable(R.drawable.circle_background) img.setTextColor(ContextCompat.getColor(context, R.color.white)) } else { img.background = null img.setTextColor(ContextCompat.getColor(context, R.color.grayBlack)) } } //set the selected position on item Click private fun userSelection(img: TextView, position: Int) { mItemClickListener.itemClick(position) if (position != oldPosition) { mArrayList[position].isDateSelected = true img.setTextColor(ContextCompat.getColor(context, R.color.white)) img.background = context.resources.getDrawable(R.drawable.circle_background) mArrayList[oldPosition].isDateSelected = false notifyItemChanged(oldPosition) oldPosition = position } } inner class DaysViewHolder(view: View) : RecyclerView.ViewHolder(view) { private var txtDays: TextView = view.findViewById(R.id.txt_Days) fun bind(days: String) { txtDays.text = days } } inner class DateViewHolder(view: View) : RecyclerView.ViewHolder(view) { var txtDate: TextView = view.findViewById(R.id.txt_Date) var imgEventIcon: AppCompatImageView = view.findViewById(R.id.imgEventIcon) @SuppressLint("LogNotTimber") fun bind(dayValue: Int, displayMonth: Int, displayYear: Int, currentMonth: Int, currentYear: Int) { if (displayMonth == currentMonth && displayYear == currentYear) { txtDate.visibility = View.VISIBLE } else { txtDate.visibility = View.GONE } txtDate.text = dayValue.toString() } } override fun getItemViewType(position: Int): Int { return mArrayList[position].viewType } interface ItemClickListener { fun itemClick(position: Int) } fun currentSelectedDatePosition(position: Int) { mLastSelectedDatePosition = position + 7 } } _______________________________________________ implementation _______________________________________________ //set Calendar Date val cal = Calendar.getInstance(Locale.ENGLISH) cal.time = getDateObject(currentDate!!)!! customCalender?.setCalendar(cal) //get Calendar Date override fun onDestroy() { if (customCalender?.getCurrentSelectedDate() != null) { EventBus.getDefault().post(CurrentSelectedDate(customCalender?.getCurrentSelectedDate()!!)) } super.onDestroy() } _______________________________________________
0 notes
Text
Things To Be Considered Before Hiring an Android Developer
Android continues to lead the world mobile app industry, currently accounting for more than 80% of it. Over 80% of global smartphone consumers prefer Android mobile phones and devices over other operating systems such as iOS and Windows. The Google Play Store currently has millions of applications available to users in a variety of ways. However, with such a large number of applications already available mostly on Android App Store, it is critical for Android developers to create highly competitive applications in order to stay ahead of the competition.It is not enough to have a good app idea; an Android app developer must also have all of the necessary skills and talents to make a good and high-performing application for each and every unique business need.
Developing alluring and user-driven Android applications nowadays necessitates extensive knowledge and awareness of many languages, tools, and technologies. In reality, developing the application with Android market fragmentation, different Android devices, and screen sizes in mind is also necessary to provide a smooth and consistent customer experience for users and displays.
All of these factors require the selection of an Android app developer who possesses all of the relevant talents and competencies.Here are the qualities you should look for in an Application programming developer before hiring them for your next project.
Well expertise and grasp of Java and Kotlin:
Java and Kotlin are now the two required programming languages for developing Android applications. And, depending on the needs of your project, your developer should be able to use both. The developer must be able to use more recent versions of Java and Kotlin, as well as understand their syntax. This is the first and most significant talent to look for when selecting an Android application developer.
XML knowledge:
XML was established as the standard method of data encoding for Android applications. It is a structured markup language with many similarities to HTML, such as angled brackets, tag kinds, deep nesting of elements, and so on. Having a thorough understanding and expertise of XML will assist developers in producing high-quality code while designing app layouts. As a result, it is critical to seek out a developer with experience in building app layouts using XML.
Practical knowledge of the Android SDK:
The Android Software Development Kit, or SDK, is a comprehensive toolbox that developers must be aware of. This toolkit includes tools for everything from designing through developing, debugging,testing, and deploying an application. The Android SDK also includes libraries such as Gradle, which ensures that applications are developed in a unified manner. And the developer you choose for your project must understand how to use and integrate this full kit for better, more efficient, faultless, and fast application development.
Knowledge of Android Studio:
Android Studio is a must-have tool in the toolkit of any Android application developer. It is a full-featured Integrated Development Environment (IDE) that includes additional features coding, auto-complete suggestions, easy code debugging, and more, all of which help developers effortlessly write code and build high-performing applications. Today, hiring a developer who is well-versed in Android Studio is a requirement.
API expertise:
As an Android application developer, you might be interested in learning about other user-driven features such as calendar access, etc. Look for developers working with major Android application development businesses who provide APIs and explain how to utilize these APIs and queries in a secure manner. Knowing the use of APIs also makes it easier for developers to access the APIs from Android applications. Choosing a developer with this talent can enable smooth installation and integration of features in your programme such as search results for local places, monitoring users' whereabouts, incorporating reference maps in apps, and more.
Database management expertise:
If your application generates big amounts of data, it may be more challenging to handle that data and databases for data maintenance. Cloud services such as Parse and Firebase provide simple APIs for saving this data in the cloud and making it accessible to all Android devices. Developers must also understand how to sync data between a distant database and local storage in order to enable offline availability, which allows users to utilize the programme to some level even if there is no internet service. That's a fantastic method to boost consumer involvement. So, seek for this talent before hiring an Android developer for your project.
Material design knowledge:
In recent times, Android has adopted Material Design, a set of new modern user interface standards and guidelines.Moreover, it is now required for app developers to examine and adhere to these principles when creating Android application interfaces.
Having a thorough understanding of all of these Android app development abilities can assist developers in executing the full application development process swiftly and flawlessly, resulting in a bug-free, well-designed, personalized, and secure application. Staying ahead of your competition on the Google App Store is difficult today, which makes it critical to have your project produced by a professional in Android application development who possesses all of the talents discussed in this article.
BiTS is a highly skilled and proficient Android app developer associated with the best Android app developers in India.We a very high client satisfaction rate, as well as industry-leading software development standards. If you want to create the most efficient and user-friendly apps for your clients then you can contact BiTS Informatics.
#android#androiddevelopment#androidapp#android app development#android app developers#mobile app development
0 notes
Text
All 101 announcements from Google I/O ‘17
It’s been a busy three days here in Mountain View, as more than 7,000 developers joined us at Shoreline Amphitheatre for this year’s Google I/O. From AI to VR, and everything in between, here’s an exhaustive—we mean that—recap of everything we announced.
1. The Google Assistant is already available on more than 100 million devices! 2. Soon, with Google Lens—a new way for computers to “see”—you’ll be able to learn more about and take action on the things around you, while you’re in a conversation with your Assistant. 3. We’ve brought your Google Assistant to iPhones. 4. Call me maybe? With new hands-free calling on Google Home, you’ll be able to make calls with the Assistant to landlines and mobile numbers in U.S. and Canada for free. 5. You can now type to your Google Assistant on eligible Android phones and iPhones. 6. Bonjour. Later this year people in Australia, Canada, France, Germany and Japan will be able to give the Assistant on Google Home a try. 7. And Hallo. Soon the Assistant will roll out to eligible Android phones in Brazilian Portuguese, French, German and Japanese. By the end of the year the Assistant will support Italian, Korean and Spanish. 8. We’re also adding transactions and payments to your Assistant on phones—soon you can order and pay for food and more, with your Assistant. 9. With 70+ home automation partners, you can water your lawn and check the status of your smoke alarm with the Assistant on Google Home and phones. 10. Soon you’ll get proactive notifications for reminders, flight delays and traffic alerts with the Assistant on Google Home and phones. With multi-user support, you can control the type of notifications to fit your daily life. 12. Listen to all your favorite tunes. We’ve added Deezer and Soundcloud as partners, plus Spotify’s free music offering coming soon. 12. Bluetooth support is coming to Google Home, so you can play any audio from your iOS or Android device. 13. Don’t know the name of a song, but remember a few of the lyrics? Now you can just ask the Assistant to “play that song that goes like...” and list some of the lyrics. 14. Use your voice to play your favorite shows and more from 20+ new partners (HBO NOW, CBS All Access, and HGTV) straight to your TV. 15. With visual responses from your Assistant on TVs with Chromecast, you’ll be able to see Assistant answers on the biggest screen in your house. 16. You can stream with your voice with Google Home on 50 million Cast and Cast-enabled devices. 17. For developers, we're bringing Actions on Google to the Assistant on phones—on both Android and iOS. Soon you’ll find conversation apps for the Assistant that help you do things like shopping for clothes or ordering food from a lengthy menu. 18. Also for developers, we’re adding ways for you to get data on your app's usage and performance, with a new console. 19. We’re rolling out an app directory, so people can find apps from developers directly in the Google Assistant. 20. People can now also create shortcuts for apps in the Google Assistant, so instead of saying "Ok Google, ask Forecaster Joe what's the surf report for the Outer Banks," someone can just say their personal shortcut, like "Ok Google, is the surf up?" 21. Last month we previewed the Google Assistant SDK, and now we’re updating it with hotword support, so developers can build devices that are triggered by a simple "Ok Google." 22. We’re also adding to the SDK the ability to have both timers and alarms. 23. And finally, we’re launching our first developer competition for Actions on Google.
24. With the addition of Smart Reply to Gmail on Android and iOS, we’re using machine learning to make responding to emails easier for more than a billion Gmail users. 25. New Cloud TPUs—the second generation of our custom hardware built specifically for machine learning—are optimized for training ML models as well as running them, and will be available in the Google Compute Engine. 26. And to speed up the pace of open machine-learning research, we’re introducing the TensorFlow Research Cloud, a cluster of 1,000 Cloud TPUs available for free to top researchers. 27. Google for Jobs is our initiative to use our products to help people find work, using machine learning. Through Google Search and the Cloud Jobs API, we’re committed to helping companies connect with potential employees and job seekers with available opportunities. 28. The Google Cloud Jobs API is helping customers like Johnson & Johnson recruit the best candidates. Only months after launching, they’ve found that job seekers are 18 percent more likely to apply on its career page now they are using Cloud Jobs API. 29. With Google.ai, we’re pulling all our AI initiatives together to put more powerful computing tools and research in the hands of researchers, developers and companies. We’ve already seen promising research in the fields of pathology and DNA research. 30. We must go deeper. AutoML uses neural nets to design neural nets, potentially cutting down the time-intensive process of setting up an AI system, and helping non-experts build AI for their particular needs. 31. We’ve partnered with world-class medical researchers to explore how machine learning could help improve care for patients, avoid costly incidents and save lives. 32. We introduced a new Google Cloud Platform service called Google Cloud IoT Core, which makes it easy for Google Cloud customers to gain business insights through secure device connections to our rich data and analytics tools.
33. We first launched Google Photos two years ago, and now it has more than 500 million monthly users. 34. Every day more than 1.2 billion photos and videos are uploaded to Google Photos. 35. Soon Google Photos will give you sharing suggestions by selecting the right photos, and suggesting who you should send them to based on who was in them 36. Shared libraries will let you effortlessly share photos with a specific person. You can share your full photo library, or photos of certain people or from a certain date forward. 37. With photo books, once you select the photos, Google Photos can curate an album for you with all the best shots, which you can then print for $9.99 (20-page softcover) or $19.99 (20-page hardcover), in the U.S. for now. 38. Google Lens is coming to Photos later this year, so you’ll be able to look back on your photos to learn more or take action—like find more information about a painting from a photo you took in a museum.
39. We reached 2 billion monthly active devices on Android! 40. Android O, coming later this year, is getting improvements to “vitals” like battery life and performance, and bringing more fluid experiences to your smaller screen, from improved notifications to autofill. 41. With picture-in-picture in Android O, you can do two tasks simultaneously, like checking your calendar while on a Duo video call. 42. Smart text selection in Android O improves copy and paste to recognize entities on the screen—like a complete address—so you can easily select text with a double tap, and even bring up an app like Maps to help navigate you there. 43. Our emoji are going through a major design refresh in Android O. 44. For developers, the first beta release of Android O is now available. 45. We introduced Google Play Protect—a set of security protections for Android that’s always on and automatically takes action to keep your data and device safe, so you don’t have to lift a finger. 46. The new Find My Device app helps you locate, ring, lock and erase your lost Android devices—phones, tablets, and even watches. 47. We previewed a new initiative aimed at getting computing into the hands of more people on entry-level Android devices. Internally called Android Go, it’s designed to be relevant for people who have limited data connectivity and speak multiple languages. 48. Android Auto is now supported by 300 car models, and Android Auto users have grown 10x since last year. 49. With partners in 70+ countries, we’re seeing 1 million new Android TV device activations every two months, doubling the number of users since last year. 50. We’ve refreshed the look and feel of the Android TV homescreen, making it easy for people to find, preview and watch content provided by apps. 51. With new partners like Emporio Armani, Movado and New Balance, Android Wear now powers almost 50 different watches. 52. We shared an early look at TensorFlow Lite, which is designed to help developers take advantage of machine learning to improve the user experience on Android. 53. As part of TensorFlow Lite, we’re working on a Neural Network API that TensorFlow can take advantage of to accelerate computation. 54. An incredible 82 billion apps were downloaded from Google Play in the last year. 55. We honored 12 Google Play Awards winners—apps and games that give their fans particularly delightful and memorable experiences. 56. We’re now previewing Android Studio 3.0, focused on speed and Android platform support. 57. We’re making Kotlin an officially supported programming language in Android, with the goal of making Android development faster and more fun. 58. And we’ll be collaborating with JetBrains, the creators of Kotlin, to move Kotlin into a nonprofit foundation. 59. Android Instant Apps are now open to all developers, so anyone can build and publish apps that can be run without requiring installation. 60. Thousands of developers from 60+ countries are now using Android Things to create connected devices that have easy access to services like the Google Assistant, TensorFlow and more. 61. Android Things will be fully released later this year. 62. Over the last year, the number of Google Play developers with more than 1 million installs grew 35 percent. 63. The number of people buying on Google Play grew by almost 30 percent this past year. 64. We’re updating the Google Play Console with new features to help developers improve your app's performance and quality, and grow your business on Google Play. 65. We’re also adding a new subscriptions dashboard in the Play Console, bringing together data like new subscribers and churn so you can make better business decisions. 66. To make it easier and more fun for developers to write robust apps, we announced a guide to Android app architecture along with a preview of Architecture Components. 67. We’re adding four new tools to the Complications API for Android Wear, to help give users more informative watch faces. 68. Also for Android Wear, we’re open sourcing some components in the Android Support Library.
69. More Daydream-ready phones are coming soon, including the Samsung Galaxy S8 and S8+, LG’s next flagship phone, and devices from Motorola and ASUS. 70. Today there are 150+ applications available for Daydream. 71. More than 2 million students have gone on virtual reality Expeditions using Google Cardboard, with more than 600 tours available. 72. We’re expanding Daydream to support standalone VR headsets, which don't require a phone or PC. HTC VIVE and Lenovo are both working on devices, based on a Qualcomm reference design. 73. Standalone Daydream headsets will include WorldSense, a new technology based on Tango which enables the headset to track your precise movements in space, without any extra sensors. 74. The next smartphone with Tango technology will be the ASUS ZenFone AR, available this summer. 75. We worked with the Google Maps team to create a new Visual Positioning Service (VPS) for developers, which helps devices quickly and accurately understand their location indoors. 76. We’re bringing AR to the classroom with Expeditions AR, launching with a Pioneer Program this fall. 77. We previewed Euphrates, the latest release of Daydream, which will let you capture what you’re seeing and cast your virtual world right onto the screen in your living room, coming later this year. 78. A new tool for VR developers, Instant Preview, lets developers make changes on a computer and see them reflected on a headset in seconds, not minutes. 79. Seurat is a new technology that makes it possible to render high-fidelity scenes on mobile VR headsets in real time. Somebody warn Cameron Frye. 80. We’re releasing an experimental build of Chromium with an augmented reality API, to help bring AR to the web.
81. Soon you’ll be able to watch and control 360-degree YouTube videos and live streams on your TV, and use your game controller or remote to pan around an immersive experience. 82. Super Chat lets fans interact directly with YouTube creators during live streams by purchasing highlighted chat messages that stay pinned to the top of the chat window. We previewed a developer integration that showed how the Super Chat API can be used to trigger actions in the real world—such as turning the lights on and off in a creator's apartment. 83. A new feature in the YouTube VR app will soon let people watch and discuss videos together.
84. We announced that we will make Fabric’s Crashlytics the primary crash reporting product in Firebase. 85. We’re bringing phone number authentication to Firebase, working closely with the Fabric Digits team, so your users can sign in to your apps with their phone numbers. 86. New Firebase Performance Monitoring will help diagnose issues resulting from poorly performing code or challenging network conditions. 87. We’ve improved Firebase Cloud Messaging. 88. For game developers, we’ve built Game Loop support & FPS monitoring into Test Lab for Android, allowing you to evaluate your game’s frame rate before you deploy. 89. We’ve taken some big steps to open source many of our Firebase SDKs on GitHub. 90. We’re expanding Firebase Hosting to integrate with Cloud Functions, letting you can do things like send a notification when a user signs up or automatically create thumbnails when an image is uploaded to Cloud Storage. 91. Developers interested in testing the cutting edge of our products can now sign up for a Firebase Alpha program. 92. We’re adding two new certifications for web developers, in addition to the Associate Android Developer Certification announced last year.<br/>93. We opened an Early Access Program for <a href="http://ift.tt/2qCjmQO, a new analytics tool in API.ai that helps developers monitor the activity in their chatbots.<br/>94. We’ve completely <a href="http://ift.tt/2rAzsYd AdMob</a>, which helps developers promote, measure and monetize mobile apps, with a new user flow and publisher controls.<br/>95. AdMob is also now <a href="http://ift.tt/2qClecq with Google Analytics for Firebase</a>, giving developers a complete picture of ads revenue, mediation revenue and in-app purchase revenue in one place.<br/>96. With a new <a href="http://ift.tt/2rAiyZN Payment API</a>, developers can enable easy in-app or online payments for customers who already have credit and debit cards stored on Google properties.<br/>97. We’re introducing <a href="http://ift.tt/2qCldoS ways for merchants to engage and reward customers</a>, including the new Card Linked Offers API.<br/>98. We’re introducing a <a href="http://ift.tt/2rAFMzf options for ads placement through Universal App Campaigns</a> to help users discover your apps in the Google Play Store.<br/>99. An <a href="http://ift.tt/2qCgT96 to Smart Bidding strategies</a> in Universal App Campaigns helps you gain high-value users of your apps—like players who level-up in your game or the loyal travelers who book several flights a month.<br/>100. A new program, <a href="http://ift.tt/2rAgRvC Attribution Partners</a>, integrates data into AdWords from seven third-party measurement providers so you can more easily find and take action on insights about how users engage with your app.<br/>101. Firebase partnered up with Google Cloud to offer <a href="http://ift.tt/2qCh7wT storage for up to 10 gigabytes in BigQuery</a> so you can quickly, easily and affordably run queries on it.</p></div></div> <div class="block-paragraph"><div class="rich-text"><p>That’s all, folks! Thanks to everyone who joined us at I/O this year, whether in person, at an I/O Extended event or via the live stream. See you in 2018.</p></div></div>
Publicado en Official Google Blog http://ift.tt/2rAQUwC vía IFTTT
0 notes
Text
Custom Calendar in android studio kotlin
https://ift.tt/2p3EFMH
The custom Calendar in android studio kotlin
_______________________________________________ Xml _______________________________________________ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://ift.tt/nIICcg" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg_bottom_sheet_dialog_fragment" android:orientation="vertical"> <androidx.appcompat.widget.LinearLayoutCompat android:id="@+id/ll_Main" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_24" android:orientation="vertical"> <com.android.showMotionRealtor.feature.dasboard.view.schedule.customcalender.CustomCalendar android:id="@+id/custom_calender" android:layout_width="match_parent" android:layout_height="wrap_content" /> </androidx.appcompat.widget.LinearLayoutCompat> </LinearLayout> _______________________________________________ CustomCalendar.kt _______________________________________________ package com.android.showMotionRealtor.feature.dasboard.view.schedule.customcalender import android.app.Dialog import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import com.android.showMotionRealtor.R import com.android.showMotionRealtor.core.util.MAX_CALENDAR_COLUMN import com.android.showMotionRealtor.core.util.mEventDateFormat import com.android.showMotionRealtor.model.CalendarData import com.android.showMotionRealtor.model.EventMessage import com.zendesk.util.DateUtils import java.text.ParseException import java.text.SimpleDateFormat import java.util.* import kotlin.collections.ArrayList /** * Created by Jeetesh Surana. */ class CustomCalendar : LinearLayout { // private var mUserSelectedDate: Long? = 0L private var mDialog : Dialog? = null private var mUserSelectedDate: Date? = null private var previousButton: ImageView? = null private var nextButton: ImageView? = null private var currentDate: TextView? = null private var rvCalender: RecyclerView? = null private val formatter = SimpleDateFormat("MMMM yyyy", Locale.ENGLISH) private val cal = Calendar.getInstance(Locale.ENGLISH) private val calendarData = ArrayList<CalendarData>() private val events: ArrayList<EventMessage> = ArrayList() private var mDateAdapter: DateAdapter? = null private val mWeekName = ArrayList<String>() var mCustomCalenderListener: CustomCalenderListener? = null constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { setWeekName() initializeUILayout() setRecyclerView() setUpCalenderData() setPreviousButtonClickEvent() setNextButtonClickEvent() } constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) private fun initializeUILayout() { val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater val mView = inflater.inflate(R.layout.calendar_layout, this) previousButton = mView.findViewById(R.id.previous_month) nextButton = mView.findViewById(R.id.next_month) currentDate = mView.findViewById(R.id.display_current_date) rvCalender = mView.findViewById(R.id.rv_CustomCalender) } private fun setPreviousButtonClickEvent() { previousButton!!.setOnClickListener { cal.add(Calendar.MONTH, -1) setUpCalenderData() } } private fun setNextButtonClickEvent() { nextButton!!.setOnClickListener { cal.add(Calendar.MONTH, 1) setUpCalenderData() } } private fun setUpCalenderData() { calendarData.clear() val dayValueInCells = ArrayList<Date>() val mCal = cal.clone() as Calendar // set month in cal mCal.set(Calendar.DAY_OF_MONTH, 1) // get the start date in week val firstDayOfTheMonth = mCal.get(Calendar.DAY_OF_WEEK) - 1 mCal.add(Calendar.DAY_OF_MONTH, -firstDayOfTheMonth) //getting dates while (dayValueInCells.size < MAX_CALENDAR_COLUMN) { dayValueInCells.add(mCal.time) mCal.add(Calendar.DAY_OF_MONTH, 1) } //set the title of month val sDate = formatter.format(cal.time) currentDate!!.text = sDate //set the week name for (i in mWeekName.indices) { calendarData.add(CalendarData(null, mWeekName[i], 0, false)) } //set the Dates for (i in dayValueInCells.indices) { if (mUserSelectedDate != null && DateUtils.isSameDay(dayValueInCells[i], mUserSelectedDate)) { calendarData.add(CalendarData(dayValueInCells[i], null, 1, true)) mDateAdapter!!.currentSelectedDatePosition(position = i) } else { calendarData.add(CalendarData(dayValueInCells[i], null, 1, false)) } } //notify adapter mDateAdapter!!.notifyDataSetChanged() } private fun setWeekName() { mWeekName.clear() mWeekName.add("S") mWeekName.add("M") mWeekName.add("T") mWeekName.add("W") mWeekName.add("T") mWeekName.add("F") mWeekName.add("S") } private fun setRecyclerView() { val dateToday = Date() val reminderDate = convertStringToDate("31-08-2019") val reminderDate2 = convertStringToDate("25-08-2019") if (reminderDate!!.after(dateToday) || reminderDate == dateToday) { events.add(EventMessage(1, "Birthday", reminderDate)) } if (reminderDate2!!.after(dateToday) || reminderDate == dateToday) { events.add(EventMessage(2, "Friendship Day !", reminderDate2)) } val layoutManager = GridLayoutManager(context, 7, RecyclerView.VERTICAL, false) rvCalender!!.layoutManager = layoutManager mDateAdapter = DateAdapter(context, calendarData, cal, events, object : DateAdapter.ItemClickListener { override fun itemClick(position: Int) { if (mDialog != null){ mDialog!!.dismiss() mUserSelectedDate = calendarData[position].monthlyDates!! } } }) rvCalender!!.adapter = mDateAdapter } private fun convertStringToDate(dateInString: String): Date? { val format = SimpleDateFormat(mEventDateFormat, Locale.ENGLISH) var date: Date? = null try { date = format.parse(dateInString) } catch (e: ParseException) { e.printStackTrace() } return date } /*fun setCurrentDate(userSelectedDate: Date) { mUserSelectedDate = userSelectedDate setUpCalenderData() }*/ fun setCalendar(mCal: Calendar) { mUserSelectedDate = mCal.time cal.time = mCal.time setUpCalenderData() } fun getCurrentSelectedDate(): Date { return calendarData[mDateAdapter!!.mLastSelectedDatePosition].monthlyDates!! } fun setCustomCalenderListener(customCalenderListener: CustomCalenderListener) { mCustomCalenderListener = customCalenderListener } fun dismissDialog(dialog: Dialog) { mDialog = dialog } interface CustomCalenderListener { fun currentSelectedDatePosition(position: Int) } } _______________________________________________ DateAdapter.kt _______________________________________________ package com.android.showMotionRealtor.feature.dasboard.view.schedule.customcalender import android.annotation.SuppressLint import android.content.Context import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView import androidx.appcompat.widget.AppCompatImageView import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import com.android.showMotionRealtor.R import com.android.showMotionRealtor.model.CalendarData import com.android.showMotionRealtor.model.EventMessage import java.util.* import kotlin.collections.ArrayList /** * Created by Jeetesh Surana. */ class DateAdapter(var context: Context, var mArrayList: java.util.ArrayList<CalendarData> = ArrayList(), var currentDate: Calendar, val allEvents: ArrayList<EventMessage> = ArrayList(), var mItemClickListener: ItemClickListener) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { var oldPosition: Int = 0 var mLastSelectedDatePosition = -1 private var dateCal = Calendar.getInstance() private var allDate: Int? = null private var displayMonth: Int? = null private var displayYear: Int? = null private var currentMonth: Int? = null private var currentYear: Int? = null override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { var view: View? = null when (viewType) { 0 -> { view = LayoutInflater.from(parent.context).inflate(R.layout.list_days, parent, false) return DaysViewHolder(view!!) } 1 -> { view = LayoutInflater.from(parent.context).inflate(R.layout.list_date, parent, false) return DateViewHolder(view!!) } } return null!! } override fun getItemCount(): Int { return mArrayList.size } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { when (holder.itemViewType) { 0 -> { (holder as DaysViewHolder).bind(mArrayList[position].mDays!!) } 1 -> { dateCal.time = mArrayList[position].monthlyDates!! allDate = dateCal.get(Calendar.DAY_OF_MONTH) displayMonth = dateCal.get(Calendar.MONTH) + 1 displayYear = dateCal.get(Calendar.YEAR) currentMonth = currentDate.get(Calendar.MONTH) + 1 currentYear = currentDate.get(Calendar.YEAR) (holder as DateViewHolder).bind(allDate!!, displayMonth!!, displayYear!!, currentMonth!!, currentYear!!) setSelectionUI((holder).txtDate, position) holder.txtDate.setOnClickListener { mItemClickListener.itemClick(position) if (mLastSelectedDatePosition != -1 && mLastSelectedDatePosition != position) { mArrayList[mLastSelectedDatePosition].isDateSelected = false } mLastSelectedDatePosition = position mArrayList[position].isDateSelected = true notifyDataSetChanged() } val eventCalendar = Calendar.getInstance() for (i in 0 until allEvents.size) { eventCalendar.time = allEvents[i].reminderDate!! if (allDate == eventCalendar.get(Calendar.DAY_OF_MONTH) && displayMonth == eventCalendar.get(Calendar.MONTH) + 1 && displayYear == eventCalendar.get(Calendar.YEAR)) { holder.imgEventIcon.visibility = View.VISIBLE } } } } } //set the selected position private fun setSelectionUI(img: TextView, position: Int) { if (mArrayList[position].isDateSelected) { img.background = context.resources.getDrawable(R.drawable.circle_background) img.setTextColor(ContextCompat.getColor(context, R.color.white)) } else { img.background = null img.setTextColor(ContextCompat.getColor(context, R.color.grayBlack)) } } //set the selected position on item Click private fun userSelection(img: TextView, position: Int) { mItemClickListener.itemClick(position) if (position != oldPosition) { mArrayList[position].isDateSelected = true img.setTextColor(ContextCompat.getColor(context, R.color.white)) img.background = context.resources.getDrawable(R.drawable.circle_background) mArrayList[oldPosition].isDateSelected = false notifyItemChanged(oldPosition) oldPosition = position } } inner class DaysViewHolder(view: View) : RecyclerView.ViewHolder(view) { private var txtDays: TextView = view.findViewById(R.id.txt_Days) fun bind(days: String) { txtDays.text = days } } inner class DateViewHolder(view: View) : RecyclerView.ViewHolder(view) { var txtDate: TextView = view.findViewById(R.id.txt_Date) var imgEventIcon: AppCompatImageView = view.findViewById(R.id.imgEventIcon) @SuppressLint("LogNotTimber") fun bind(dayValue: Int, displayMonth: Int, displayYear: Int, currentMonth: Int, currentYear: Int) { if (displayMonth == currentMonth && displayYear == currentYear) { txtDate.visibility = View.VISIBLE } else { txtDate.visibility = View.GONE } txtDate.text = dayValue.toString() } } override fun getItemViewType(position: Int): Int { return mArrayList[position].viewType } interface ItemClickListener { fun itemClick(position: Int) } fun currentSelectedDatePosition(position: Int) { mLastSelectedDatePosition = position + 7 } } _______________________________________________ implementation _______________________________________________ //set Calendar Date val cal = Calendar.getInstance(Locale.ENGLISH) cal.time = getDateObject(currentDate!!)!! customCalender?.setCalendar(cal) //get Calendar Date override fun onDestroy() { if (customCalender?.getCurrentSelectedDate() != null) { EventBus.getDefault().post(CurrentSelectedDate(customCalender?.getCurrentSelectedDate()!!)) } super.onDestroy() } _______________________________________________
via Blogger https://ift.tt/2Mzz1Lb
0 notes
Text
Custom Calendar in android studio kotlin
https://ift.tt/2Ho5Zep
Custom Calendar in android studio kotlin
_______________________________________________
Xml
_______________________________________________
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="https://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_bottom_sheet_dialog_fragment"
android:orientation="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/ll_Main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_24"
android:orientation="vertical">
<com.android.showMotionRealtor.feature.dasboard.view.schedule.customcalender.CustomCalendar
android:id="@+id/custom_calender"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.appcompat.widget.LinearLayoutCompat>
</LinearLayout>
_______________________________________________
CustomCalendar.kt
_______________________________________________
package com.android.showMotionRealtor.feature.dasboard.view.schedule.customcalender
import android.app.Dialog
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.android.showMotionRealtor.R
import com.android.showMotionRealtor.core.util.MAX_CALENDAR_COLUMN
import com.android.showMotionRealtor.core.util.mEventDateFormat
import com.android.showMotionRealtor.model.CalendarData
import com.android.showMotionRealtor.model.EventMessage
import com.zendesk.util.DateUtils
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.*
import kotlin.collections.ArrayList
/**
* Created by Jeetesh Surana.
*/
class CustomCalendar : LinearLayout {
// private var mUserSelectedDate: Long? = 0L
private var mDialog : Dialog? = null
private var mUserSelectedDate: Date? = null
private var previousButton: ImageView? = null
private var nextButton: ImageView? = null
private var currentDate: TextView? = null
private var rvCalender: RecyclerView? = null
private val formatter = SimpleDateFormat("MMMM yyyy", Locale.ENGLISH)
private val cal = Calendar.getInstance(Locale.ENGLISH)
private val calendarData = ArrayList<CalendarData>()
private val events: ArrayList<EventMessage> = ArrayList()
private var mDateAdapter: DateAdapter? = null
private val mWeekName = ArrayList<String>()
var mCustomCalenderListener: CustomCalenderListener? = null
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
setWeekName()
initializeUILayout()
setRecyclerView()
setUpCalenderData()
setPreviousButtonClickEvent()
setNextButtonClickEvent()
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
private fun initializeUILayout() {
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val mView = inflater.inflate(R.layout.calendar_layout, this)
previousButton = mView.findViewById(R.id.previous_month)
nextButton = mView.findViewById(R.id.next_month)
currentDate = mView.findViewById(R.id.display_current_date)
rvCalender = mView.findViewById(R.id.rv_CustomCalender)
}
private fun setPreviousButtonClickEvent() {
previousButton!!.setOnClickListener {
cal.add(Calendar.MONTH, -1)
setUpCalenderData()
}
}
private fun setNextButtonClickEvent() {
nextButton!!.setOnClickListener {
cal.add(Calendar.MONTH, 1)
setUpCalenderData()
}
}
private fun setUpCalenderData() {
calendarData.clear()
val dayValueInCells = ArrayList<Date>()
val mCal = cal.clone() as Calendar
// set month in cal
mCal.set(Calendar.DAY_OF_MONTH, 1)
// get the start date in week
val firstDayOfTheMonth = mCal.get(Calendar.DAY_OF_WEEK) - 1
mCal.add(Calendar.DAY_OF_MONTH, -firstDayOfTheMonth)
//getting dates
while (dayValueInCells.size < MAX_CALENDAR_COLUMN) {
dayValueInCells.add(mCal.time)
mCal.add(Calendar.DAY_OF_MONTH, 1)
}
//set the title of month
val sDate = formatter.format(cal.time)
currentDate!!.text = sDate
//set the week name
for (i in mWeekName.indices) {
calendarData.add(CalendarData(null, mWeekName[i], 0, false))
}
//set the Dates
for (i in dayValueInCells.indices) {
if (mUserSelectedDate != null && DateUtils.isSameDay(dayValueInCells[i], mUserSelectedDate)) {
calendarData.add(CalendarData(dayValueInCells[i], null, 1, true))
mDateAdapter!!.currentSelectedDatePosition(position = i)
} else {
calendarData.add(CalendarData(dayValueInCells[i], null, 1, false))
}
}
//notify adapter
mDateAdapter!!.notifyDataSetChanged()
}
private fun setWeekName() {
mWeekName.clear()
mWeekName.add("S")
mWeekName.add("M")
mWeekName.add("T")
mWeekName.add("W")
mWeekName.add("T")
mWeekName.add("F")
mWeekName.add("S")
}
private fun setRecyclerView() {
val dateToday = Date()
val reminderDate = convertStringToDate("31-08-2019")
val reminderDate2 = convertStringToDate("25-08-2019")
if (reminderDate!!.after(dateToday) || reminderDate == dateToday) {
events.add(EventMessage(1, "Birthday", reminderDate))
}
if (reminderDate2!!.after(dateToday) || reminderDate == dateToday) {
events.add(EventMessage(2, "Friendship Day !", reminderDate2))
}
val layoutManager = GridLayoutManager(context, 7, RecyclerView.VERTICAL, false)
rvCalender!!.layoutManager = layoutManager
mDateAdapter = DateAdapter(context, calendarData, cal, events, object : DateAdapter.ItemClickListener {
override fun itemClick(position: Int) {
if (mDialog != null){
mDialog!!.dismiss()
mUserSelectedDate = calendarData[position].monthlyDates!!
}
}
})
rvCalender!!.adapter = mDateAdapter
}
private fun convertStringToDate(dateInString: String): Date? {
val format = SimpleDateFormat(mEventDateFormat, Locale.ENGLISH)
var date: Date? = null
try {
date = format.parse(dateInString)
} catch (e: ParseException) {
e.printStackTrace()
}
return date
}
/*
fun setCurrentDate(userSelectedDate: Date) {
mUserSelectedDate = userSelectedDate
setUpCalenderData()
}*/
fun setCalendar(mCal: Calendar) {
mUserSelectedDate = mCal.time
cal.time = mCal.time
setUpCalenderData()
}
fun getCurrentSelectedDate(): Date {
return calendarData[mDateAdapter!!.mLastSelectedDatePosition].monthlyDates!!
}
fun setCustomCalenderListener(customCalenderListener: CustomCalenderListener) {
mCustomCalenderListener = customCalenderListener
}
fun dismissDialog(dialog: Dialog) {
mDialog = dialog
}
interface CustomCalenderListener {
fun currentSelectedDatePosition(position: Int)
}
}
_______________________________________________
DateAdapter.kt
_______________________________________________
package com.android.showMotionRealtor.feature.dasboard.view.schedule.customcalender
import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.android.showMotionRealtor.R
import com.android.showMotionRealtor.model.CalendarData
import com.android.showMotionRealtor.model.EventMessage
import java.util.*
import kotlin.collections.ArrayList
/**
* Created by Abhin.
*/
class DateAdapter(var context: Context, var mArrayList: java.util.ArrayList<CalendarData> = ArrayList(), var currentDate: Calendar, val allEvents: ArrayList<EventMessage> = ArrayList(), var mItemClickListener: ItemClickListener) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
var oldPosition: Int = 0
var mLastSelectedDatePosition = -1
private var dateCal = Calendar.getInstance()
private var allDate: Int? = null
private var displayMonth: Int? = null
private var displayYear: Int? = null
private var currentMonth: Int? = null
private var currentYear: Int? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
var view: View? = null
when (viewType) {
0 -> {
view = LayoutInflater.from(parent.context).inflate(R.layout.list_days, parent, false)
return DaysViewHolder(view!!)
}
1 -> {
view = LayoutInflater.from(parent.context).inflate(R.layout.list_date, parent, false)
return DateViewHolder(view!!)
}
}
return null!!
}
override fun getItemCount(): Int {
return mArrayList.size
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (holder.itemViewType) {
0 -> {
(holder as DaysViewHolder).bind(mArrayList[position].mDays!!)
}
1 -> {
dateCal.time = mArrayList[position].monthlyDates!!
allDate = dateCal.get(Calendar.DAY_OF_MONTH)
displayMonth = dateCal.get(Calendar.MONTH) + 1
displayYear = dateCal.get(Calendar.YEAR)
currentMonth = currentDate.get(Calendar.MONTH) + 1
currentYear = currentDate.get(Calendar.YEAR)
(holder as DateViewHolder).bind(allDate!!, displayMonth!!, displayYear!!, currentMonth!!, currentYear!!)
setSelectionUI((holder).txtDate, position)
holder.txtDate.setOnClickListener {
mItemClickListener.itemClick(position)
if (mLastSelectedDatePosition != -1 && mLastSelectedDatePosition != position) {
mArrayList[mLastSelectedDatePosition].isDateSelected = false
}
mLastSelectedDatePosition = position
mArrayList[position].isDateSelected = true
notifyDataSetChanged()
}
val eventCalendar = Calendar.getInstance()
for (i in 0 until allEvents.size) {
eventCalendar.time = allEvents[i].reminderDate!!
if (allDate == eventCalendar.get(Calendar.DAY_OF_MONTH) && displayMonth == eventCalendar.get(Calendar.MONTH) + 1 && displayYear == eventCalendar.get(Calendar.YEAR)) {
holder.imgEventIcon.visibility = View.VISIBLE
}
}
}
}
}
//set the selected position
private fun setSelectionUI(img: TextView, position: Int) {
if (mArrayList[position].isDateSelected) {
img.background = context.resources.getDrawable(R.drawable.circle_background)
img.setTextColor(ContextCompat.getColor(context, R.color.white))
} else {
img.background = null
img.setTextColor(ContextCompat.getColor(context, R.color.grayBlack))
}
}
//set the selected position on item Click
private fun userSelection(img: TextView, position: Int) {
mItemClickListener.itemClick(position)
if (position != oldPosition) {
mArrayList[position].isDateSelected = true
img.setTextColor(ContextCompat.getColor(context, R.color.white))
img.background = context.resources.getDrawable(R.drawable.circle_background)
mArrayList[oldPosition].isDateSelected = false
notifyItemChanged(oldPosition)
oldPosition = position
}
}
inner class DaysViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private var txtDays: TextView = view.findViewById(R.id.txt_Days)
fun bind(days: String) {
txtDays.text = days
}
}
inner class DateViewHolder(view: View) : RecyclerView.ViewHolder(view) {
var txtDate: TextView = view.findViewById(R.id.txt_Date)
var imgEventIcon: AppCompatImageView = view.findViewById(R.id.imgEventIcon)
@SuppressLint("LogNotTimber")
fun bind(dayValue: Int, displayMonth: Int, displayYear: Int, currentMonth: Int, currentYear: Int) {
if (displayMonth == currentMonth && displayYear == currentYear) {
txtDate.visibility = View.VISIBLE
} else {
txtDate.visibility = View.GONE
}
txtDate.text = dayValue.toString()
}
}
override fun getItemViewType(position: Int): Int {
return mArrayList[position].viewType
}
interface ItemClickListener {
fun itemClick(position: Int)
}
fun currentSelectedDatePosition(position: Int) {
mLastSelectedDatePosition = position + 7
}
}
_______________________________________________
implementation
_______________________________________________
//set Calendar Date
val cal = Calendar.getInstance(Locale.ENGLISH)
cal.time = getDateObject(currentDate!!)!!
customCalender?.setCalendar(cal)
//get Calendar Date
override fun onDestroy() {
if (customCalender?.getCurrentSelectedDate() != null) {
EventBus.getDefault().post(CurrentSelectedDate(customCalender?.getCurrentSelectedDate()!!))
}
super.onDestroy()
}
_______________________________________________
via Blogger https://ift.tt/2L5Lu7r
0 notes